import os

file = 'zen.txt'
with open('zen.txt', 'r') as f:
    print(f.readline())

#用abspath获取绝对路径
full_path = os.path.abspath(file)
print('绝对路径：' + full_path)

#获取目录
dir = os.path.dirname(full_path)
print('目录：' + dir)

#获取文件名
print('文件名：' + os.path.basename(full_path))

#获取文件大小
print(f'文件大小：{os.path.getsize(full_path)}')

#拼接路径
file2 = 'new_file.txt'
print(f'拆分路径：{os.path.join(dir, file2)}')